import request from '@/utils/request'

// 生成一次性密码 - 与运维端保持一致
export function hxAddSingleKey(query) {
  return request({
    url: '/offlinePassword/passwordGeneration',
    method: 'get',
    params: query
  })
}

// 生成一次性密码（旧版本，保留兼容性）
export function generateOneTimePassword(lockMac) {
  return request({
    url: '/lock/room/oneTimePassword',
    method: 'get',
    params: { lockMac }
  })
}

// 远程开锁
export function hxOpenDoorLock(lockMac) {
  return request({
    url: '/lock/room/hxOpenDoorLock?lockMac='+ lockMac,
    method: 'get',
  })
}

// 获取锁状态
export function getLockStatus(lockMac) {
  return request({
    url: '/lock/room/lockStatus',
    method: 'get',
    params: { lockMac }
  })
}

// 获取锁二维码
export function getLockQrcode(data) {
  return request({
    url: '/lock/room/qrcode',
    method: 'post',
    data: data
  })
}

// 重启门锁
export function restartLock(lockMac) {
  return request({
    url: '/lock/room/restartLock',
    method: 'get',
    params: { lockMac }
  })
}

// 同步门锁时间
export function syncLockTime(lockMac) {
  return request({
    url: '/lock/room/syncTime',
    method: 'get',
    params: { lockMac }
  })
}

// 取消远程开锁
export function cancelOpenLock(lockMac) {
  return request({
    url: '/lock/room/cancelOpenLock',
    method: 'get',
    params: { lockMac }
  })
}

// 获取门锁日志列表
export function apartmentLockLogList(query) {
  return request({
    url: '/lock/room/apartmentLockLogList',
    method: 'get',
    params: query
  })
}

// 添加房间离线密码
export function addPassword(query) {
  return request({
    url: '/lock/room/hxAddPassword',
    method: 'get',
    params: query
  })
}

// 修改用户有效期
export function tenantRenewRoom(query) {
  return request({
    url: '/lock/room/hxTenantRenewRoom',
    method: 'get',
    params: query
  })
}

// 冻结用户
export function roomFrozenTenant(data) {
  return request({
    url: '/lock/room/hxRoomFrozenTenant',
    method: 'get',
    params: data
  })
}

// 解冻用户
export function defrostUser(data) {
  return request({
    url: '/lock/room/defrostUser',
    method: 'get',
    params: data
  })
}

// 查询设备周期性密码列表
export function listPeriodicPasswords(deviceMac, homeId, showExpired) {
  return request({
    url: '/lock/periodic/password/listByMacAndHomeId',
    method: 'get',
    params: { deviceMac, homeId, showExpired }
  })
} 